package com.example.test.config;

import org.activiti.engine.impl.history.HistoryLevel;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

import javax.sql.DataSource;

/**
 * @author ：dengjue
 * @date ：Created in 2021/7/25 22:53
 * @description ：
 */
@Configuration
public class ActivitiConfiguration {

    @Autowired
    private DataSource dataSource;
    @Autowired
    private PlatformTransactionManager manager;

    // 自定义流程配置
    @Bean
    public SpringProcessEngineConfiguration processEngineConfiguration(){
        SpringProcessEngineConfiguration configuration =  new SpringProcessEngineConfiguration();
        configuration.setActivityFontName("宋体");
        configuration.setLabelFontName("宋体");
        configuration.setAnnotationFontName("宋体");
        configuration.setDatabaseType(SpringProcessEngineConfiguration.DATABASE_TYPE_MYSQL);
        configuration.setDataSource(dataSource);
        configuration.setTransactionManager(manager);
        configuration.setDatabaseSchemaUpdate(SpringProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
        configuration.setHistoryLevel(HistoryLevel.FULL);
        configuration.setDatabaseSchema("ACT"); //工作流表以ACT开头
        return configuration;
    }

}
